# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=winpty
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.4.3
pkgrel=1
pkgdesc='An interface similar to a Unix pty-master for communicating with Windows console programs (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://github.com/rprichard/winpty'
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=(https://github.com/rprichard/${_realname}/archive/${pkgver}.tar.gz
        winpty-0.4.3-mingw-fix.patch)
sha256sums=('093037c39f9c899d79b74d5e15ff74fb59a98c492c5ed621e97e1090c3442865'
            '543cf42edec61dd036eb33f7b8874a7ce926faaaa1a3c5c1b439f4dab6e682d2')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/winpty-0.4.3-mingw-fix.patch"
}

build() {
  [[ -d "build-${MSYSTEM}" ]] && rm -rf "build-${MSYSTEM}"
  cp -r "${_realname}-${pkgver}" "build-${MSYSTEM}"

  cd "${srcdir}/build-${MSYSTEM}"
  ./configure
  
  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make PREFIX=${pkgdir}${MINGW_PREFIX} install

  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
